class Ex3
  
  $dict = Hash.new("")
  def check_available(k)
    ($dict[k] ==  "") ? false : true
  end
  
  def get_dict(k)
    return $dict[k]
  end
  
  def add_dict(k,v)
    $dict[k] = v 
  end
  
  def run()
    
    cont = true
    while (cont == true)
      puts "Nhap tu khoa: "
      k = gets.chomp.to_s
      if (check_available(k) == true)
        puts(get_dict(k))
      else
        puts "Nhap dinh nghia:"
        val = gets.chomp.to_s
        add_dict(k,val)
      end
      puts "Tiep tuc (yes or no):"
      ans = gets.chomp.to_s
      while (ans != "yes" && ans != "no")
        puts "Tiep tuc (yes or no):"
        ans = gets.chomp.to_s
      end
      if (ans == "no")
        cont = false
      end
    end
    
  end
end


  ex3 = Ex3.new()
  ex3.run()